﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ProjectTest.Models.Business
{
    public class QLNhomNguoiDung
    {
            DBTestDataContext db = new DBTestDataContext();
            //them nhom nguoi dung
            public void Create(NhomNguoiDung qs)
            {
                try
                {
                    db.NhomNguoiDungs.InsertOnSubmit(qs);
                    db.SubmitChanges();
                }
                catch (Exception)
                {

                    throw;
                }
            }
            //sau thong tin cau hoi
            public void Edit(NhomNguoiDung NNDEdited, int maNND)
            {
                NhomNguoiDung NND = db.NhomNguoiDungs.SingleOrDefault(p => p.MaNhomND == maNND);
                try
                {
                    UpdateInfo(NND, NNDEdited);
                    db.SubmitChanges();
                }
                catch (Exception)
                {

                    throw;
                }
            }

            private void UpdateInfo(NhomNguoiDung NND, NhomNguoiDung NNDEdited)
            {
                NND.MaQuyen = NND.MaQuyen;
                NND.TenNhomND = NND.TenNhomND;
            }
            //xoa thong tin cau hoi theo ma
            public void Delete(int maNND)
            {
                NhomNguoiDung ch = db.NhomNguoiDungs.SingleOrDefault(p => p.MaNhomND == maNND);
                try
                {
                    db.NhomNguoiDungs.DeleteOnSubmit(ch);
                    db.SubmitChanges();
                }
                catch (Exception)
                {

                    throw;
                }
            }


    }
}